import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import sys
import math
import csv



#===========================================================


AsCores = [  (0.0 , 0.5 , 0.0)
            ,(0.0 , 0.5 , 0.5)
            ,(0.0 , 0.0 , 1.0)
            ,(0.5 , 0.5 , 0.0)
            ,(1.0 , 0.0 , 0.0)
           ]


#===========================================================

def improve_legend(ax=None):
    if ax is None:
        ax = plt.gca()

    for spine in ax.spines:
        ax.spines[spine].set_visible(False)
        
    k = -1
    for line in ax.lines:
        k = k + 1
        data_x, data_y = line.get_data()
        if 0 < (len(data_x)-1):
            right_most_x = data_x[len(data_x)-1]
            right_most_y = data_y[len(data_y)-1]
            ax.annotate(nomes[k], xy=(1, right_most_y), xytext=(6,0), color=line.get_color(), 
                xycoords = ax.get_yaxis_transform(), textcoords="offset points",
                size=14, va="center")

    ax.legend().set_visible(False)


#===========================================================



fields = ['Day','Total']

df1 = pd.read_csv('sim45.csv', usecols=fields)
df1['cor']=0

df2 = pd.read_csv('sim49.csv', usecols=fields)
df2['cor']=1

df3 = pd.read_csv('sim50.csv', usecols=fields)
df3['cor']=2

df4 = pd.read_csv('sim51.csv', usecols=fields)
df4['cor']=3

df5 = pd.read_csv('sim55.csv', usecols=fields)
df5['cor']=4


nomes = ['45', '49' ,'50','51','55']
frames = [df1, df2, df3, df4, df5]



todos = pd.concat(frames)



#===========================================================



#sns.set(style="darkgrid")
#sns.set(style="whitegrid")
#sns.set(palette="bright")
#sns.color_palette("hls", 7)



ax = sns.lineplot(x="Day", y="Total"
                  , hue="cor"
                  , palette=AsCores
                  , data=todos)


improve_legend(ax)

ax.set_title('Effect of Avg. Graph Degree', fontsize=18);

ax.set_xlabel("Day",fontsize=16)
ax.set_ylabel("Total Infected",color="black",fontsize=16)
ax.tick_params(axis='x', labelsize=16)
ax.tick_params(axis='y', labelsize=16)

plt.grid()

plt.subplots_adjust(
top=0.88,
bottom=0.135,
left=0.125,
right=0.9,
hspace=0.2,
wspace=0.2
)

plt.draw()


plt.savefig('Figure-10a.eps', format='eps')
plt.savefig('Figure-10a.png', dpi=400)

plt.show ()

